package com.ruoyi.web.controller.project;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.project.mapper.ProAssetMapper;
import com.ruoyi.project.vo.ProAssetEcharts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/project/assetbing")
public class ProAssetEchartsController extends BaseController {
    @Autowired
    private ProAssetMapper proAssetMapper;

    @GetMapping("/assetpie")
    public AjaxResult assetpie(){
        List<ProAssetEcharts> proasset = proAssetMapper.selectAsset();
        ArrayList<ProAssetEcharts> proassetEcharts = new ArrayList<>();
        for(ProAssetEcharts echarts: proasset){
            ProAssetEcharts proassetEcharts1 = new ProAssetEcharts();
            proassetEcharts1.setName(echarts.getName());
            proassetEcharts1.setValue(echarts.getValue());
            proassetEcharts.add(proassetEcharts1);
        }
        for(ProAssetEcharts proassetEchart : proassetEcharts) {
            System.out.println("饼状图数据"+"=========="+proassetEchart.getName()+proassetEchart.getValue());
        }

        return AjaxResult.success(proassetEcharts);
    }
}
